/* 类可以单继承（一个类），多实现（多个接口） */
class Person {
   constructor(public name: string, public age: number) {}
   eat(food?: string) {
      console.log(this.name, "eat", food ? food : "饭");
   }
}
interface IProduct {
   name: string;
   value: number;
}

interface IWorker {
   work: (hours: number) => IProduct;
}

interface IFighter {
   fight: (enemy: Person) => Person;
}

class Student extends Person implements IWorker, IFighter {
   work(hours: number): IProduct {
      return {
         name: "学生作品",
         value: hours,
      };
   }

   fight(enemy: Person): Person {
      return this.age >= enemy.age ? enemy : this;
   }
}

const zs = new Student("张三疯", 60);
zs.eat();
console.log(zs.work(10000));
console.log(zs.fight(new Person("黄四郎", 50)));
